<!DOCTYPE html>
<html>
<head>
  <title>Hello state!</title>
  <script src="../build/react.js"></script>
  <script src="../build/react-dom.js"></script>
  <script src="../build/browser.min.js"></script>
</head>
<body>
  <div id="demo-form"></div>
  <script type="text/babel">
    var MyForm = React.createClass({
      getInitialState: function () {
        return {
          topic: 'Cooking',
          liked: false
        };
      },
      handleClick: function () {
        this.refs.myCountInput.focus();
      },
      handleClickLiked: function () {
        this.setState({ liked: !this.state.liked});
      },
      handleChange: function (event) {
        this.setState({topic: event.target.value});
      },
      render: function () {
        var topic = this.state.topic;
        var liked = this.state.liked ? 'like' : 'haven\'t liked';
        return (
          <div>
            <input type="text" ref="myCountInput" value={topic} onChange={this.handleChange} />
            <input type="button" value="Focus" onClick={this.handleClick} />
            <input type="button" value={liked} onClick={this.handleClickLiked} />
            <p>I {liked} {topic}</p>
          </div>
        );
      }
    });
    ReactDOM.render(
      <MyForm />,
      document.getElementById('demo-form')
    );
  </script>
</body>
</html>